package com.algorithm.combination;

import java.util.Stack;

public class Pailie {
    // Cmn
    //    问题3：
//    从m个球里（编号为1,2,3...,m）一次取n个球，其中m>n，记录取出球的编号，枚举所有的可能性

    static Stack<Integer> stack = new Stack<Integer>();
    static int cnt = 0;

    public static void testRecursion3() {
        //C5 3
        int[] data = {1, 2, 3, 4, 5};
        recursion3(data, 0, 3, 0);
        System.out.println(cnt);
    }

    public static void recursion3(int[] array, int curnum, int maxnum, int indexnum) {
        if (curnum == maxnum) {
            cnt++;
            System.out.println(stack);
            return;
        }
        for (int i = indexnum; i < array.length; i++) {
            if (!stack.contains(array[i])) {
                stack.push(array[i]);
                recursion3(array, curnum + 1, maxnum, i);
                stack.pop();
            }
        }
    }

    public static void main(String[] args) {
        testRecursion3();
    }
}
